from django.shortcuts import render
from rest_framework.views import APIView
from rest_framework.response import Response
# Create your views here.
from .models import miniProgram
from .serializers import miniProGramModelSerializer
from rest_framework import status

class MiniProgramFilterAPIView(APIView):

    def get(self,request,type,language,*args,**kwargs):
        queryset = miniProgram.objects.filter(type=type,language=language)
        ser = miniProGramModelSerializer(instance=queryset,many=True)
        return Response(ser.data,status=status.HTTP_200_OK)



class newsPublishAPIView(APIView):

    def get(self,request,*args,**kwargs):
        queryset = miniProgram.objects.all().order_by('-id')[0:10]
        ser = miniProGramModelSerializer(instance=queryset,many=True)
        return Response(ser.data,status=status.HTTP_200_OK)